package day03;

public class IfDemo {
    public static void main(String[] args) {

        int num = 5;
        int flag = num > 0 ? 1 : -1;
        System.out.println(flag); //1

        int a = 8, b = 5;
        int max = a > b ? a : b;
        System.out.println("max=" + max);
/*
        //满500打8折:
        double price = 300.0; //消费金额  带数(600.0,300.0)
        if (price >= 500) {   //满500
            price *= 0.8; //打8折
        }
        System.out.println("最终消费金额为:" + price);*/
/*
        //判断成绩是否合法
        int score = 555; //带数(95,-5,555)
        if (score >= 0 && score <= 100) {
            System.out.println("成绩合法");
        }
        System.out.println("继续执行...");*/

/*
        //满500打8折，不满500打9折:
        double price = 300.0;   //带数(600.0,300.0)
        if (price >= 500) { //满
            price *= 0.8;
        } else { //不满
            price *= 0.9;
        }
        System.out.println("最终消费金额为:" + price);*/

        //判断成绩合法还是不合法
        int score = 95; //带数(95,-5,555)
        if (score >= 0 && score <= 100) {
            System.out.println(score + "是合法成绩");
        } else {
            System.out.println(score + "是不合法成绩");
        }

        //满2000打5折，满1000不满2000打7折，满500不满1000打8折，不满500打9折:
        double price = 6000.0; //带数(2000.0,1000.0,600.0,300.0)
        if (price >= 2000) {
            price *= 0.5;
        } else if (price >= 1000) {
            price *= 0.7;
        } else if (price >= 500) {
            price *= 0.8;
        } else {
            price *= 0.9;
        }
        System.out.println("最终消费金额为:" + price);

    }

}
